﻿@model dynamic

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
    <head>
		<title>netPost Usage Examples</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="x-ua-compatible" content="IE=8" />
        <style type="text/css">
        </style>
	</head>
    <body>
        <h3>$.netPost Usage Examples</h3>
        <p>Send object <button id="anObject">Send</button></p>
        <pre>
                { Id: 1, What: 'TV', Dimensions: [10, 20, 30] }
        </pre>

        <p>Send array of complex objects <button id="arrayOfObjects">Send</button></p>
        <pre>
                [
                    { Id: 1, What: 'TV', Dimensions: [10, 20, 30] },
                    { Id: 2, What: 'Car', Dimensions: [120, 210, 160] }
                ]
        </pre>

        <p>Send complex object containing all information about a Person <button id="personObject">Send</button></p>
        <pre>
                {
                    FirstName: 'John',
                    LastName: 'Doe',
                    Age: 120,
                    DateOfBirth: '1893-10-24 10:54:00',
                    ResidentialAddress: {
                        City: 'New York',
                        Street: 'Funky',
                        TypeOfStreet: 'Avenue',
                        Number: 951,
                        RoomNumber: 41,
                        PostalCode: '10001'
                    },
                    OtherAddresses: [
                        {
                            City: 'New York',
                            Street: 'Crazy',
                            TypeOfStreet: 'Way',
                            Number: 334,
                            PostalCode: '10002'
                        }
                    ],
                    Social: {
                        Sites: [
                            {
                                SiteName: 'Facebook',
                                Id: 2,
                                Login: 'cookie.monster'
                            }
                        ]
                    }
                }
        </pre>
    </body>
	<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.7.2.js")"></script>
	<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.netpost-1.0.0.js")"></script>
    <script type="text/javascript">
        $('#anObject').click(function () {
            $.netpost({
                url: '@Url.Action("AnObject")',
                data: {Id: 1, What: 'TV', Dimensions: [10, 20, 30] }
            }).success(function (data) { alert(data.message); });
        });
        
        $('#arrayOfObjects').click(function () {
            $.netpost({
                url: '@Url.Action("ArrayOfObjects")',
                data: [
                    { Id: 1, What: 'TV', Dimensions: [10, 20, 30] },
                    { Id: 2, What: 'Car', Dimensions: [120, 210, 160] }
                ]
            }).success(function (data) { alert(data.message); });
        });

        $('#personObject').click(function () {
            $.netpost({
                url: '@Url.Action("PersonObject")',
                data: {
                    FirstName: 'John',
                    LastName: 'Doe',
                    Age: 120,
                    DateOfBirth: '1893-10-24 10:54:00',
                    ResidentialAddress: {
                        City: 'New York',
                        Street: 'Funky',
                        TypeOfStreet: 'Avenue',
                        Number: 951,
                        RoomNumber: 41,
                        PostalCode: '10001'
                    },
                    OtherAddresses: [
                        {
                            City: 'New York',
                            Street: 'Crazy',
                            TypeOfStreet: 'Way',
                            Number: 334,
                            PostalCode: '10002'
                        }
                    ],
                    Social: {
                        Sites: [
                            {
                                SiteName: 'Facebook',
                                Id: 2,
                                Login: 'cookie.monster'
                            }
                        ]
                    }
                }
            }).success(function (data) { alert(data.message); });
        });
    </script>    
</html>